
<script>
    function expandItem(el,main){
        main = $(main);
        el = $(el);
        if (el == null ) return;
        var icon = main.getElement('div.country_proflie_body_icon');
        var display = el.style.display;
        if (display == 'none') {
            el.style.display = 'block';
            if (icon){
                icon.addClass('expand');
                icon.removeClass('collapse');
            }
        } else {
            el.style.display = 'none';
            icon.addClass('collapse');
            icon.removeClass('expand');
        }
        
        
        
    }
    function expandAll(){
        var icons = $$('.country_proflie_body_icon');
        els = $$('.country_proflie_body_field_container');
        for( var i = 0; i < els.length; i++ ){
            els[i].style.display = 'block';
        }
        for( var i = 0; i < icons.length; i++ ){
            icons[i].addClass('expand');
            icons[i].removeClass('collapse');
        }
    }
    function collapseAll(){
        var icons = $$('.country_proflie_body_icon');
        els = $$('.country_proflie_body_field_container');
        for( var i = 0; i < icons.length; i++ ){
            els[i].style.display = 'none';
            
        }
        for( var i = 0; i < els.length; i++ ){
            icons[i].addClass('collapse');
            icons[i].removeClass('expand');
        }
    }
    function showtooltip(el){
        el = $(el);
        var position = el.getPosition();
        var tooltip = $('tipDiv');
        tooltip.style.visibility = 'visible';
        tooltip.style.top = position.y+'px';
        
    }
    function hiddentooltip(){
        var tooltip = $('tipDiv');
        tooltip.style.visibility = 'hidden'
    }
    function showFieldDetail(id,country_id){
        window.location.href = en4.core.baseUrl+'countries/fields/id/'+id+'/cid/'+country_id;
    }
    function showAllFieldDetail(id){
        window.location.href = en4.core.baseUrl+'countries/allfields/#'+id;
    }
en4.core.runonce.add(function() {
    collapseAll();
    
});
</script>

<?php $index = 0; $id = "country_proflie_body_field_container_".$index?>

<div class="country_proflie_body_command">
    <span onclick="collapseAll();">Collapse all </span>
    <span>|</span>
    <span onclick="expandAll();"> Expand All</span> 
    
</div>
<?php foreach($this->parentFields as $parent): ?>
   <div onclick="expandItem('<?php echo $id ?>',this)" class="country_proflie_body"> <div> <?php echo ucfirst($parent->title) ?> :: </div><div class="country_proflie_body_name"><?php echo ucfirst($this->country->title);?></div> 
        <div class="country_proflie_body_icon expand"></div>
   </div>
   
   <?php if (isset($this->fields[$parent->field_id])): $fields = $this->fields[$parent->field_id]?>
        <div id="<?php echo $id;?>" class="country_proflie_body_field_container">
        <?php  foreach($fields as $field): ?>
           <div class="country_proflie_body_field_title"><span onclick="showAllFieldDetail('<?php echo ucfirst(substr($field->title,0,1)) ?>');"><?php echo ucfirst($field->title) ?>:</span><span onmouseover="showtooltip(this);" onclick="showFieldDetail('<?php echo $field->field_id?>','<?php echo $field->country_id ?>');" onmouseout="hiddentooltip();" class="country_proflie_body_field_title_icon"></span></div>  
           <div class="country_proflie_body_field_detail"><?php echo $field->detail ?></div>  
        <?php endforeach;?>
        </div>
   <?php endif;?>
   <?php $index++; $id = "country_proflie_body_field_container_".$index?>
<?php endforeach;?>

<div id="tipDiv" style="position: absolute; visibility: hidden; z-index: 100; width: 159px; font-family: Verdana, arial, helvetica, sans-serif; font-size: 8pt; color: rgb(0, 0, 0); border: 0px none rgb(102, 102, 102); padding: 0px; left: 970px; top: 546px;"><table border="0" +="" "width="159" height="65"><tbody><tr><td align="center"><img src="<?php echo $this->baseUrl()?>/application/modules/Country/externals/images/field_listing_tooltip.gif" border="0"></td></tr><tr><td valign="top"><span style="font-family:Verdana, arial, helvetica, sans-serif; position:absolute; font-size:8pt; color:#000000;"></span></td></tr></tbody></table></div>